package VN.EDU.IMIC.DEVELOPER.LETRONGKHANH.JDBC_DEMO;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;

import com.sqlserver.imic.edu.vn.ConnectionManager.SqlConnection;

public class CallableStament_demo02 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Connection objConnection;
		SqlConnection obj = new SqlConnection();
		
	try {
		objConnection = obj.OpenConnection("DESKTOP-F43Q9GJ", "sa", "12345", "QLBH", 1433); 
		if(!objConnection.isClosed()){
			ResultSet objRs;
			CallableStatement objCmst;
		objCmst = objConnection.prepareCall("select * from KHACHHANG");
		objRs = objCmst.executeQuery();
	while(objRs.next()){
		System.out.println("Ma khach hang: "+ objRs.getInt(1));
		System.out.println("Ho va ten: "+ objRs.getString("TenGiaoDich"));
		System.out.println();
	}
		}else {
			System.out.println("ket noi that bai");
		}
	} catch (Exception e) {
		e.printStackTrace();
	}

}
}
